package com.example.api.controller;


import com.example.api.common.core.CommonResult;
import com.example.api.dto.LoginRequest;
import com.example.api.entity.Users;
import com.example.api.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/user")
@CrossOrigin
public class UserController {

    @Autowired
    private UsersService usersService;

    // 获取全部用户信息
    @GetMapping("/all")
    public CommonResult getAllUsers() {
        List<Users> getAll = usersService.list();
        return CommonResult.success(getAll);
    }


    @PostMapping("/login")
    public CommonResult login(@RequestBody LoginRequest request) {
        return usersService.login(request);
    }

}
